package com.lailai.constant;

/**
 * 统一错误码定义
 */
public enum ErrorCode {
    // 系统级错误 (1000-1999)
    SYSTEM_ERROR(1000, "系统内部错误"),
    PARAMETER_ERROR(1001, "参数错误"),
    DATABASE_ERROR(1002, "数据库操作错误"),
    NETWORK_ERROR(1003, "网络异常"),

    // 认证授权错误 (2000-2999)
    AUTHENTICATION_FAILED(2000, "认证失败"),
    AUTHORIZATION_FAILED(2001, "授权失败"),
    TOKEN_EXPIRED(2002, "令牌已过期"),
    ACCESS_DENIED(2003, "访问被拒绝"),

    // 路由相关错误 (3000-3999)
    ROUTE_NOT_FOUND(3001, "路由不存在"),
    ROUTE_ALREADY_EXISTS(3002, "路由已存在"),
    ROUTE_CONFIG_ERROR(3003, "路由配置错误"),

    // 版本相关错误 (4000-4999)
    VERSION_NOT_FOUND(4001, "版本不存在"),
    VERSION_ALREADY_EXISTS(4002, "版本号已存在"),
    VERSION_CONFIG_ERROR(4003, "版本配置错误"),

    // 业务对象相关错误 (5000-5999)
    BIZ_OBJECT_NOT_FOUND(5001, "业务对象不存在"),
    BIZ_OBJECT_VALIDATION_FAILED(5002, "业务对象验证失败");

    private final int code;
    private final String message;

    ErrorCode(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public String getCodeAsString() {
        return String.valueOf(code);
    }
}
